// JavaScript Document
// MousePositionControl es un GControl que muestra una ventana de informacion con las 
// posiciones Latitud y Longitud del mouse al posarse sobre el mapa.

function MousePositionControl() {
}

MousePositionControl.prototype = new GControl();

MousePositionControl.prototype.initialize = function(map) {
  var container = document.createElement("div");
  this._setControlStyle(container);

  GEvent.addDomListener(map, "mousemove", function(latlng) {
	var lat = latlng.lat().toString().substr(0,10);
	var lng = latlng.lng().toString().substr(0,10);
    container.innerHTML = 'lat:'+ lat + ' | lng:' + lng;
  });
  
  GEvent.addDomListener(map, "mouseout", function() {
    container.innerHTML = "";
  });
  
  map.getContainer().appendChild(container);
  return container;
}

// By default, the control will appear in the top left corner of the
// map with 7 pixels of padding.
MousePositionControl.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(3, 20));
}

// Sets the proper CSS for the given button element.
MousePositionControl.prototype._setControlStyle = function(content) {
	with(content.style){
       color = "#616161";
       fontFamily = "Arial";
       padding = "2px";
	   fontSize = "11px";
       textAlign = "center";
	}
}
